package com.zeedev.flyingsaucer.modules.IndicatorModule.impl;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.zeedev.flyingsaucer.modules.IndicatorModule.interfaces.Indicator;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 * User: James
 * Date: 12/31/10
 * Time: 3:46 PM
 */
@Singleton
public class IndicatorImpl implements Indicator {

    @Inject
    public IndicatorImpl() {
        modal = false;
        indicator = false;
    }

    public enum Properties {
        MODAL_INDICATOR,
        INDICATOR
    }

    PropertyChangeSupport pcs = new PropertyChangeSupport(this);

    Boolean modal;
    Boolean indicator;


    @Override
    public synchronized Boolean getIndicatorStatus() {
        return indicator;
    }

    @Override
    public synchronized void setModalIndicatorStatus(Boolean modal) {
        Boolean oldValue = this.modal;
        this.modal = modal;
        pcs.firePropertyChange(Properties.MODAL_INDICATOR.name(), oldValue, modal);
    }

    @Override
    public synchronized void setIndicatorStatus(Boolean indicator) {
        Boolean oldValue = this.indicator;
        this.indicator = indicator;
        pcs.firePropertyChange(Properties.INDICATOR.name(), oldValue, indicator);
    }

    @Override
    public synchronized Boolean getModalIndicatorStatus() {
        return modal;
    }


    @Override
    public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
        pcs.removePropertyChangeListener(listener);
    }

    @Override
    public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
        pcs.addPropertyChangeListener(listener);
    }

    @Override
    public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        pcs.addPropertyChangeListener(propertyName, listener);
    }

    @Override
    public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        pcs.removePropertyChangeListener(propertyName, listener);
    }
}
